<template>
	<eui-popup ref="auditSendAfsPopup" background-color="#fff" type="bottom" :mask-click="false">
		<view class="popup-content">
			<view class="popup-title flex just-between">
				<view style="font-weight: bold;">
					退货退款设置
				</view>
				<bcm-close-btn @click="close" />
			</view>
			<scroll-view scroll-y="true" style="height: 25vh;padding: 20rpx 36rpx 0 30rpx;">
				<view class="auditSendAfsPopup">
					<view class="flex" style="align-items: baseline;">
						<view>是否发退货配送：</view>
						<view>
							<radio-group @change="selectRefundDeliveryFlag" :value="refundDeliveryFlag">
								<view class="flex">
									<radio value="1" :checked="refundDeliveryFlag === '1'" style="width: 100%;">
										是
									</radio>
									<radio value="0" :checked="refundDeliveryFlag === '0'"
										style="width: 100%;margin-left: 20rpx;">
										否
									</radio>
								</view>
							</radio-group>
						</view>
					</view>
					<view v-if="refundDeliveryFlag == '1'" class="flex align-center" style="margin-top: 10rpx;">
						<view style="text-align: left;">期望取件时间：</view>
						<view style="padding-left:10rpx;flex:1;box-sizing: border-box;">
							<eui-datetime-picker type="datetimerange" v-model="expectPickTime" :hide-second="true"
								style="width: 90%;height: 60rpx;" :border="true" />
						</view>
					</view>
				</view>
			</scroll-view>
			<view class="bottom-1">
				<eui-button type="primary" @click="click" style="width: 45%;line-height: 40rpx;" title="确认提交" />
			</view>
		</view>
	</eui-popup>
</template>
<script>
import BcmCloseBtn from '../../components/BcmCloseBtn.vue';
import { getBcmDictList } from '../../../../hooks/bcmUseUntils';

export default {
	name: "AuditSendAfsPopup",
	props: {
		scope: {
			type: Object,
			default: {}
		},
		type: {
			type: String,
			default: 'bottom'
		},
		show: {
			type: Boolean,
			default: false
		}
	},
	components: {
		BcmCloseBtn
	},
	watch: {
		show: {
			handler(val) {
				if (val) {
					this.$refs.auditSendAfsPopup.open('bottom');
					if (!!this.scope.expectPickUpStartTime && !!this.scope.expectPickUpEndTime) {
						this.expectPickTime = [this.scope.expectPickUpStartTime, this.scope.expectPickUpEndTime]
					}
				} else {
					this.close()
				}
			},
		},
		expectPickTime() {
			// console.log(this.expectPickTime,'expectPickTime')
		}
	},
	data() {
		return {
			refundDeliveryFlag: '0',
			expectPickTime: null,
			startTime: null,
			endTime: null
		}
	},
	methods: {
		close() {
			this.$refs.auditSendAfsPopup.close();
			this.expectPickTime = null;
			this.refundDeliveryFlag = '0';
			this.$emit('close');
		},
		getBcmDictList,
		selectRefundDeliveryFlag(e) {
			this.refundDeliveryFlag = e.detail.value;
		},
		changeTime(e) {
			this.expectPickTime = e;
		},
		click() {
			if (this.refundDeliveryFlag == '1') {
				if ((!this.expectPickTime?.length || this.expectPickTime == null)) {
					uni.showToast({
						icon: 'none',
						title: '请填写上门取件时间',
					});
					return
				}
				if (new Date(this.expectPickTime[0]).getTime() < Date.now() || new Date(this.expectPickTime[1])
					.getTime() < Date.now()) {
					uni.showToast({
						icon: 'none',
						title: '开始(结束）时间应大于当前时间',
					});
					return
				}
			}
			let data = {
				dealType: '2',
				refundDeliveryFlag: this.refundDeliveryFlag,
				expectPickUpStartTime: this.refundDeliveryFlag == '1' ? this.expectPickTime[0] + ':00' : null,
				expectPickUpEndTime: this.refundDeliveryFlag == '1' ? this.expectPickTime[1] + ':00' : null
			}
			this.$emit('submit', data)
		}
	}
}
</script>
<style lang="scss" scoped>
@import "@/static/font/enjoyicon/iconfont.css";
@import "../../common/common.css";

.auditSendAfsPopup {
	::v-deep .uni-date-x {
		height: 50rpx;
		color: #000;
		font-size: 21rpx;
	}
}

.m-button {
	height: 70rpx;
	margin: 0 $uni-spacing-row-base;
	color: #fff !important;
	font-size: 32rpx;
	line-height: 70rpx;
}


.m-button-confrim {
	border: 0 !important;
	// width: 140rpx;
	// background: $uni-button-backgroud-confrim;
}

.popup-content {
	display: flex;
	flex-direction: column;
	width: 100%;
	padding: 0;
	background-color: #fff;

	.popup-title {
		display: flex;
		align-items: center;
		box-sizing: border-box;
		width: 100%;
		height: 100rpx;
		padding-right: 36rpx;
		padding-left: 30rpx;
		font-size: 33rpx;
		line-height: 100rpx;
		border-bottom: 1rpx solid #f1f1f1;
	}
}

.bottom-1 {
	display: flex;
	justify-content: center;
	flex: 0 0 auto;
	height: 70rpx;
	padding: $uni-spacing-col-sm * 0 $uni-spacing-row-sm;
	margin-bottom: 20rpx;
	background: $uni-bg-color;
}
</style>
